import {
  isObject
} from './utils';
import {
  proxyHandler
} from './handler';

//创建响应式data数据
export function createReactive(data) {
  /**proxy写法
   * proxy(data, handler);
   * handler: getter/setter
   */
  return createReactiveData(data, proxyHandler);
}



function createReactiveData(data, proxyHandler) {
  //判断data是否为object
  if (!isObject(data)) {
    //返回原始值
    return data;
  } else {
    //是对象
    return new Proxy(data, proxyHandler);
  }
}